package com.naiterui.ehp.bs.b2c.inventory.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "e_inventory_log")
public class InventoryLog implements Serializable {
    private static final long serialVersionUID = -1523708666583308824L;

    /**
     * 业务类型 预分配
     */
    public static final int BUSINESS_TYPE_PRE_ASSIGN = 1;

    /**
     * 业务类型 分仓
     */
    public static final int BUSINESS_TYPE_ASSIGN = 2;
    /**
     * 业务类型 发货
     */
    public static final int BUSINESS_TYPE_DELIVERY = 3;

    /**
     * 业务类型 取消订单
     */
    public static final int BUSINESS_TYPE_CANCEL = 4;

    /**
     * 业务类型 拒绝订单
     */
    public static final int BUSINESS_TYPE_REJECT = 5;

    /**
     * 业务类型 修改实物库存
     */
    public static final int BUSINESS_TYPE_MODIFY = 6;

    /**
     * 业务类型 修改仓库
     */
    public static final int BUSINESS_TYPE_MODIFY_WAREHOUSE = 7;

    /**
     * 业务类型 反审订单
     */
    public static final int BUSINESS_TYPE_RETURN_AUDIT = 8;

    /**
     * 变更类型 增加欲占
     */
    public static final int CHANGE_TYPE_WILL = 1;

    /**
     * 变更类型 扣减欲占，增加占用
     */
    public static final int CHANGE_TYPE_TAKE_UP = 2;

    /**
     * 变更类型 扣减占用，扣减实物库存
     */
    public static final int CHANGE_TYPE_PHYSICAL = 3;

    /**
     * 变更类型 修改实物库存
     */
    public static final int CHANGE_TYPE_MODIFY_PHYSICAL = 4;

    /**
     * 变更类型 扣减欲占
     */
    public static final int CHANGE_TYPE_REJECT = 5;

    /**
     * 变更类型 扣减占用
     */
    public static final int CHANGE_TYPE_SUB_TAKE_UP = 6;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /**
     * 订单ID
     */
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    /**
     * 订单号
     */
    @Column(name = "order_sn", nullable = false)
    private String orderSn;

    @Column(name = "warehouse_id", nullable = false)
    private Long warehouseId;

    @Column(name = "product_id", nullable = false)
    private Long productId;

    @Column(name = "sku_id", nullable = false)
    private Long skuId;

    /**
     * 业务类型  1：预分配，2：分仓 3：发货 4：取消订单 5：拒绝订单 6：修改实物库存
     */
    @Column(name = "business_type", nullable = false)
    private Integer businessType;

    /**
     * 变更类型 1：增加欲占 2：扣减欲占，增加占用，3：扣减占用，扣减实物库存 4：修改实物库存
     */
    @Column(name = "change_type", nullable = false)
    private Integer changeType;

    /**
     * 修改前实物库存
     */
    @Column(name = "physical_quantity", nullable = false)
    private Long physicalQuantity;

    /**
     * 修改前欲占库存数量
     */
    @Column(name = "will_quantity", nullable = false)
    private Long willQuantity;

    /**
     * 修改前占用库存
     */
    @Column(name = "take_up_quantity", nullable = false)
    private Long takeUpQuantity;

    /**
     * 修改数量
     */
    @Column(name = "quantity", nullable = false)
    private Integer quantity;

    @Column(name = "created_at", nullable = false)
    private Date createdAt;

    @Column(name = "created_by", nullable = false, length = 40)
    private String createdBy;

    @Column(name = "changed_at", nullable = false)
    private Date changedAt;

    @Column(name = "changed_by", nullable = false, length = 40)
    private String changedBy;

    @Version
    @Column(name = "version", nullable = false)
    private Integer version;

}
